package com.qf.elasticsearch.pojo;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.data.elasticsearch.annotations.Document;

import java.util.List;


@Document(indexName = "movies", type = "_doc")
public class Movie {
    private String id;
    private String title;
    private Integer year;
    private List<String> genre;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Integer getYear() {
        return year;
    }

    public void setYear(Integer year) {
        this.year = year;
    }

    public List<String> getGenre() {
        return genre;
    }

    public void setGenre(List<String> genre) {
        this.genre = genre;
    }

    public static void main(String[] args) throws JsonProcessingException {
        ObjectMapper objectMapper = new ObjectMapper();

        // Movie movie = objectMapper.readValue("{\"year\":1998,\"title\":\"Murder in Mind\",\"id\":\"122681\",\"genre\":[\"Crime\",\"Drama\",\"Thriller\"],\"@version\":\"1\"}", Movie.class);
        Movie movie = JSONObject.parseObject("{\"year\":1998,\"title\":\"Murder in Mind\",\"id\":\"122681\",\"genre\":[\"Crime\",\"Drama\",\"Thriller\"],\"@version\":\"1\"}", Movie.class, Feature.IgnoreNotMatch);
//        Movie movie = objectMapper.readValue("{\"year\":1998,\"title\":\"Murder in Mind\",\"id\":\"122681\",\"genre\":[\"Crime\",\"Drama\",\"Thriller\"],\"@version\":\"1\"}", Movie.class);
        System.out.println(movie);
    }
}
